perm filename KNUTH.SAI[225,JMC] blob sn#005377 filedate 1971-05-31 generic text, type T, neo UTF8
00100	begin comment race problem;
00105	preload_with
00110	[11] 0,3,1,3,4,[6] 0,
00115	1,3,2,4,[6] 0,
00120	3,4,1,2,[6] 0,
00125	2,1,2,4,[6] 0,
00130	3,3,1,4,[6] 0,
00135	4,3,1,2, [6] 0,
00140	3,1,4,2, [6] 0,
00145	4,4,3,4, [6] 0,
00150	4,3,2,1, [5] 0;
00200	integer array p[0:99];
00300	preload_with
00400	0,1,0,3,0,5,0,1;
00500	integer array c1[1:8];
00600	
00650	integer i,k;
00700	preload_with
00800	0,3,1,3,2,3,3,1;
00900	integer array c2[1:8];
01000	
01100	preload_with 
01200	0,0,2,0,4,0,6,7;
01300	integer array c3[1:8];
01400	
01500	preload_with
01600	0,0,3,0,3,0,3,3;
01700	integer array c4[1:8];
01800	
01900	integer array a[0:9],tally[0:9];
02000	
02050	boolean array easy[1:8];
02100	recursive procedure find(value integer k);
02200	begin integer t1,t2,j,jj;
02300	t1←5-p[a[c1[k]]+c2[k]];
02400	t2←5-p[a[c3[k]]+c4[k]];
02500	for j←10 step 10 until 90 do begin
02600	if p[j] = 0 then
02700		begin for jj←j+1 step 1 until j+4 do 
02800	if (p[jj]=t1) ∧ (easy[k] ∨ (p[jj+1]=t2))
02900	then begin tally[k] ← tally[k]+1; a[k]←jj;
03000	if k<8 then begin p[j]←1; find(k+1); p[j]←0 end
03100	end end;
03200	end end;
03250	for i← 10 step 10 until 90 do begin 
03275	p[i+5]←p[i+1];p[i+6]←p[i+2];p[i+7]←p[i+3] end;
03300	
03400	for k←1 step 1 until 8 do
03500	begin
03600	tally[k]←0;
03700	if c4[k]>0 then easy[k]←false else easy[k]← true;
03800	end;
03900	
04000	comment begin main program;
04100	for i←10 step 10 until 90 do
04200	begin a[0]←i+1;  p[i]←1; find(1);p[i]←0 end;
04300	for k←1 step 1 until 8 do outstr(cvs(k)&" "&cvs(tally[k])&"
04350	");
04400	end